"use strict";

/**
 * @ngdoc directive
 * @name jgappApp.directive:flowRemind
 * @description
 * # flowRemind
 */
angular
  .module("jgappApp")
  .directive("flowTransfer", function(DataService,$rootScope, openApi, Util) {
    return {
      scope: {
        taskid: "="
      },
      templateUrl: "views/directive/flowtransfer.html",
      restrict: "AE",
      link: function postLink(scope) {
        // 撤回流程
        scope.confirm = function() {
          if(!scope.userId){
            Util.Toast("请选择转交人");
            return
          }
          var param = {
            userId:scope.userId,
            taskId:scope.taskid,
          };

          DataService.getData(openApi.transferTask, param).then(function(data) {
            Util.Toast(data, {
              callback: function() {
                NativeUtil.use("close");
              },
              time: 1000
            });
            NativeUtil.use("updateProcess");
          });
        };
        scope.cancel = function() {
          $rootScope.$emit('closemasker');
        };
        $rootScope.$on('maskerClosed', function() {
            $rootScope.transfertemplate.remove()
        });
        scope.chooseusers=function(){
          scope.showSearchInput=true
        }
        scope.handleSearch=function(user){
          console.log(user);
          scope.userId=user.userId
          scope.name=user.name
          scope.showSearchInput=false

        }
        scope.apiurl=openApi.users
        scope.title="请选择转交人"
      }
    };
  });
